package com.example.ws.util;

import io.javalin.http.Context;

public class RespUtil {
  
  public static void sendResp(Context ctx, RespEntity resp) {
    ctx.json(resp, RespEntity.class);
  }

  public static void sendResp(Context ctx, int code, String message, Object data) {
    ctx.json(new RespEntity(code, message, data), RespEntity.class);
  }
  
  public static void success(Context ctx, Object data) {
    sendResp(ctx, RespEntity.CODE_SUCCESS, "success", data);
  }

  public static void success(Context ctx, String message, Object data) {
    sendResp(ctx, RespEntity.CODE_SUCCESS, message, data);
  }

  public static void error(Context ctx, String message) {
    sendResp(ctx, RespEntity.CODE_ERROR, message, null);
  }

  public static void error(Context ctx, String message, Object data) {
    sendResp(ctx, RespEntity.CODE_ERROR, message, data);
  }
  
  

}
